addOnLoad(window_load);

function window_load(){
	InitTableControl();
}

var TheTableControl;

/**初始化数据列表空间**/
function InitTableControl(){
	TheTableControl=new TableController('TheTableControl');
	TheTableControl.objTable=document.all.DummyTable;

	TheTableControl.OnAfterRowSelected=afterSelectTheRow;
	if(TheTableControl.Count()>0)
	{
		TheTableControl.SelectARow(0);
	}else{
		//initButtonStatus();
	}
}

/**根据选择的数据行的状态动态改变功能菜单的有效性**/
function afterSelectTheRow()
{
	var id = TheTableControl.getItem(5);
	var str = AjaxAction.syncCall('messageAction.getNoteDetail',id);
	content.innerHTML = str;
	titleLabel.innerHTML = TheTableControl.getItem(1);
	
}

/**全选择所有的消息**/
function selectAll(){	
	var obj = document.getElementsByName('checkbox');
	var iLen = obj.length;
	var i;
	
	for(i=0; i<iLen; ++i){
		obj[i].checked = true;
	}
}

/**取消所有被选中的item**/
function unSelectAll(){
	var obj = document.getElementsByName('checkbox');
	var iLen = obj.length;
	var i;
	
	for(i=0; i<iLen; ++i){
		obj[i].checked = false;
	}
}

/**删除当前选择的短信**/
function deleteSelectMessage(){
	var obj = document.getElementsByName('checkbox');
	var objLen = obj.length;
	var i;
	var j = 0;
	var str = "";

	for(i=0; i<objLen; ++i){
		if(obj[i].checked==true){		
			str = str + obj[i].value + ";";
			++j;
		}
	}	
	
	if(j==0){
		alert("请选择要删除的短消息.");
		return;
	}

    if( confirm( "您确实要删除吗？" ) ){
    	AjaxAction.syncCall('messageAction.setDeleteStateStr',str);
	    window.location.href = "inbox.jsp";			
	}else{
		return;
	}
}
